using Microsoft.AspNetCore.Mvc;
using Shop.Core.Share;
using Shop.IServices.Admin;
using Shop.Model.Dto.Admin.Contract;
using Shop.Model.View.Admin.Contract;

namespace Shop.AdminApi.Controllers;

/// <summary>
/// 合约审批模块
/// </summary>
[ApiController]
[Route("admin/[controller]")]
public class ApproveAContractController:ShopControllerBase
{
    private readonly IApproveAContractService _approveAContractService;
    private readonly IUserContext _userContext;

    /// <summary>
    /// 
    /// </summary>
    /// <param name="approveAContractService"></param>
    /// <param name="userContext"></param>
    public ApproveAContractController(IApproveAContractService approveAContractService,IUserContext userContext)
    {
        _approveAContractService = approveAContractService;
        _userContext = userContext;
    }
    
    /// <summary>
    /// 合同列表
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpGet("ContractSearch")]
    public AppResult<PageModel<ContractListVo>> ContractSearch([FromQuery]ContractPageSearchDto input)
        => _approveAContractService.ContractSearch(input);

    /// <summary>
    /// 状态(常量)
    /// </summary>
    /// <returns></returns>
    [HttpGet("ContractState")]
    public AppResult<List<ContractStateVo>> ContractState()
    {
        var contractVo = new List<ContractStateVo>();
        var contractOne = new ContractStateVo(){Key = -1, Value = "无效", Sort = 0};
        var contractTwo = new ContractStateVo(){Key = 0, Value = "审核中", Sort = 1};
        var contractThree = new ContractStateVo(){Key = 1, Value = "审核通过", Sort = 2};
        contractVo.Add(contractOne);
        contractVo.Add(contractTwo);
        contractVo.Add(contractThree);
        return contractVo;
    }

    /// <summary>
    /// 合同详情
    /// </summary>
    /// <param name="dto"></param>
    /// <returns></returns>
    [HttpGet("ContractInfo")]
    public AppResult<ContractVo> ContractInfo([FromQuery] long dto)
        => _approveAContractService.ContractInfo(dto);

    /// <summary>
    /// 合同审核
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("ContractReview")]
    public  async Task<AppResult> ContractReview([FromBody]ContractReviewDto input)
        => await _approveAContractService.ContractReview(input);
}